<?php
/**
 * Joomla! 2.5 - Erweiterungen programmieren
 *
 * Standard-Layout für das Frontend. Ausgabe als HTML-Tabelle.
 *
 * @package    FFTools
 * @subpackage Frontend
 * @author     chmst.de, webmechanic.biz
 * @license	   GNU/GPLv2 or later
 *
 * @todo  HTML-Ausgabe mit CSS anhübschen
 */
defined('_JEXEC') or die;

/* Das Null-Datum der Datenbank, als Vergleichswert */
$nullDate = JFactory::getDbo()->getNullDate();

/* Nach dieser Spalte wird die Tabelle sortiert */
$listOrder	= $this->escape($this->state->get('list.ordering'));

/* Die Sortierrichtung - aufsteigend oder absteigend */
$listDirn	= $this->escape($this->state->get('list.direction'));

?>
<?php echo $this->before_display ?>

<h1><?php echo JText::_('COM_FFTOOLS_SLOGAN'); ?></h1>

<?php if ($this->items) { ?>

<table>
<tr>

	<th style="background: #ccc;" class="center" width="20%">
		<?php echo JHtml::_('grid.sort', 'COM_FFTOOLS_TITLE', 'title', $listDirn, $listOrder); ?>
	</th>
	<th style="background: #ccc;" class="center" width="20%">
		<?php echo JHtml::_('grid.sort', 'COM_FFTOOLS_CATEGORY', 'category', $listDirn, $listOrder); ?>
	</th>
	<th style="background: #ccc;" class="center" width="30%">
		<?php echo JHtml::_('grid.sort', 'COM_FFTOOLS_LEND_FROM_LABEL', 'lent_from', $listDirn, $listOrder); ?>
	</th>
	<th style="background: #ccc;" class="center" width="30%">
		<?php echo JHtml::_('grid.sort', 'COM_FFTOOLS_LEND_TO_LABEL', 'lent_to', $listDirn, $listOrder); ?>
	</th>
  <th style="background: #ccc;" class="center" width="20%">
		<?php echo JHtml::_('grid.sort', 'COM_FFTOOLS_STATE', 'state', $listDirn, $listOrder); ?>
	</th>


</tr>
<?php foreach ($this->items as $item) : ?>
<tr>

  <td class="center">
	<?php
	/* Link zur Detailansicht */
    $link = JRoute::_("index.php?option=com_fftools&view=fftool&id=" .$item->id);
	echo '<a href="' .$link .'">' .$item->title .'</a>';
	?>
  </td>

	<td class="center" width="20%">
	<?php echo $this->escape($item->category); ?>
	</td>
	<td class="center" width="30%"><?php
	if ($item->lent_from != $nullDate) {
		echo JHtml::_('date', $this->escape($item->lent_from), 'd.m.Y');
	} ?>
  </td>
	</td class="center" width="30%">
	<td class="center" width="20%"><?php
	if ($item->lent_from != $nullDate) {
		echo JHtml::_('date', $this->escape($item->lent_to), 'd.m.Y');
	} ?>
  </td>
  <td class="center" width="20%"><?php 
		        switch ($this->escape($item->state)) {
        	    case '0':
        	    	echo JText::_('COM_FFTOOLS_STATE_NEW');
        	    break;
        	
        	    case '1':
        	    	echo JText::_('COM_FFTOOLS_STATE_GOOD');
        	    break;
        	
        	    case '2':
        	    	echo JText::_('COM_FFTOOLS_STATE_USED');
        	    break;
        	
        	    case '3':
        	    	echo JText::_('COM_FFTOOLS_STATE_SCRAPE');
        	    break;
        	
        	    default:
        	    	echo JText::_('COM_FFTOOLS_STATE_UNKOWN');
        	    break;
        	}?></td> 

</tr>
<?php endforeach; ?>
</table>


<form action="<?php echo JRoute::_('index.php?option=com_fftools&view=fftools'); ?>"
      method="post" name="adminForm" id="adminForm">
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="option" value="com_fftools" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>

<?php } ?>
